package com.cn.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class OOMController {
    private List<byte[]> memoryLeakList = new ArrayList<>();

    @GetMapping("/oom")
    public String triggerOOM() {
        while (true) {
            memoryLeakList.add(new byte[1024 * 1024]); // 每次分配1MB内存
        }
    }
}
